package cn.org.guhao.practice.go.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.atomic.AtomicLong;

public class WordFileThread extends Thread {

  private static final Logger logger = LoggerFactory.getLogger(WordFileThread.class);

  private Runnable target;   //线程执行目标
  private AtomicLong counter;

  public WordFileThread(Runnable target, AtomicLong counter) {
    this.target = target;
    this.counter = counter;
  }

  @Override
  public void run() {
    try {
      target.run();
    }finally {
      long c = counter.getAndDecrement();
      logger.info("execute [{}] threads", c);
    }

  }
}
